<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改旅行社信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改旅行社信息</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-form-item">
                            <label class="layui-form-label">旅行社名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="team_name" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['team_name']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">旅行社电话</label>
                            <div class="layui-input-block">
                                <input type="text" name="team_phone" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['team_phone']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">请选择地区</label>
                            <div class="layui-inline">
                                <select name="province" class="province" lay-verify="required" lay-search lay-filter="province">
                                    <option value="山东省">山东省</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="city" class="city" lay-verify="required" lay-search lay-filter="city">
                                    <option value="临沂市">临沂市</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="district" class="district" lay-verify="required" lay-search>
                                    <option value="沂水县">县/沂水县</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">详细地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="team_address" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['team_address']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">旅行社头像</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="team_icon" id="team_icon" value="{$res['team_icon']}">
                                <button type="button" class="layui-btn" id="guide_card_thumb1">旅行社头像照片</button>
                                <span>上传尺寸为1:1的照片</span>
                            </div>
                            <div  class="layui-input-block" id="upload_thumb_img_div1">
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" id="upload_thumb_img1" style="width:102px;height:102px;" src="{$res['team_icon']}">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">旅行社背景</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="team_background" id="team_background" value="{$res['team_background']}">
                                <button type="button" class="layui-btn" id="guide_card_thumb2">旅行社背景照片</button>
                                <span>上传尺寸为750px*320px的照片</span>
                            </div>
                            <div  class="layui-input-block" id="upload_thumb_img_div2">
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" id="upload_thumb_img2" style="width:200px;height:140px;" src="{$res['team_background']}">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 100px">营业开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="start" name="team_start_time" placeholder="请输入营业开始时间" lay-verify="required" value="{$res['team_start_time']}">
                            </div>
                            <label class="layui-form-label" style="width: 100px">营业结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="end" name="team_end_time" placeholder="请输入营业结束时间" lay-verify="required" value="{$res['team_end_time']}">
                            </div>
                        </div>

                        <input type="hidden" value="{$res['team_id']}" name="team_id">
                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block">
                                <div class="layui-inline" style="left: 0;">
                                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addsubmit">修改</button>
                                    <a class="layui-btn layui-btn-primary prex" data-type="prex">返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script src="/static/js/jquery-1.11.1.min.js"></script>
<script src="/static/js/area.js" type="text/javascript"></script>
<script src="/static/js/selectMore.js" type="text/javascript"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','set','upload','element','laydate'], function(){
        $ = layui.jquery;
        var  admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,form = layui.form
            ,laydate = layui.laydate
            ,upload=layui.upload;

        form.render(null,'component-form-group');
        //时间选择器
        laydate.render({
            elem: '#start'
            ,type: 'time'
            ,format:"HH:mm"
        });

        laydate.render({
            elem: '#end'
            ,type: 'time'
            ,format:"HH:mm"
        });

        //上传图片

        var uploadInst = upload.render({
            elem: '#guide_card_thumb1'
            ,url: "{:url('Common/upload')}"
            ,before: function(obj){
                $('#upload_thumb_img_div1').show();
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#upload_thumb_img1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){

                if (res.code == 1){
                    $('#team_icon').val(res.data);
                    return layer.msg(res.msg);
                }else{
                    return layer.msg(res.msg);
                }
            }
        });

        //上传图片

        var uploadInst = upload.render({
            elem: '#guide_card_thumb2'
            ,url: "{:url('Common/upload')}"
            ,before: function(obj){
                $('#upload_thumb_img_div2').show();
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#upload_thumb_img2').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){

                if (res.code == 1){
                    $('#team_background').val(res.data);
                    return layer.msg(res.msg);
                }else{
                    return layer.msg(res.msg);
                }
            }
        });

        //添加提交
        form.on('submit(addsubmit)', function(data){


            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            $.ajax({
                url: "{:url('Info/editInfo')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},
                success: function(data){
                    if (data.code === 0) {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            window.location.href = "{:url('Info/info')}";
                        });
                    }else if(data.code === 2){
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }else if(data.code === 1){
                        layer.close(loading);
                        layer.msg('修改内容不能为空',{icon:2,time:1000})
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        var $ = layui.$, active = {
            prex:function(){
                layer.confirm('确认取消本次编辑并返回吗？',function(){
                    window.location.href="{:url('Info/info')}";
                });
            }
        };

        $('.prex').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>